 package es.ats.codington.festival.services;

import java.util.ArrayList;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import es.ats.codington.festival.daos.ManagerDAOImp;
import es.ats.codington.festival.domain.Event;
import es.ats.codington.festival.interfaces.daos.IEventDAOImp;
import es.ats.codington.festival.interfaces.services.IEventService;

public class EventDAOService implements IEventService{

	int nRows = 0;
	IEventDAOImp eventDAO;

	public EventDAOService() {
		ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml");  
		ManagerDAOImp managerDAO = (ManagerDAOImp) ctx.getBean("daoManager");
		this.eventDAO = managerDAO.getEventDAO();
	}
	
	/**
	 *  GETTER methods for EventDAOService class 
	 * @return
	 */
	public Event getEventByIdService(int eventId, String usTickets){
		return eventDAO.getEventById(eventId, usTickets);
	}
	
	/**
	 *  GETTER methods for EventDAOService class 
	 * @return
	 */
	public Event getEventByIdService(int eventId){
		return eventDAO.getEventById(eventId);
	}
	
	/**
	 *  GETTER methods for EventDAOService class 
	 * @return
	 */
	public ArrayList<Event> getEventListService(){
		return eventDAO.getEventList();
	}
	
	/**
	 *  SETTER methods for EventDAOService class 
	 * @return
	 */
	public int insertEventService(Event event){
		return eventDAO.insertEvent(event);
	}
	
	/**
	 *  SETTER methods for EventDAOService class 
	 * @return
	 */
	public int updateEventService(Event uEvent){
		return eventDAO.updateEvent(uEvent);
	}
	
	/**
	 *  SETTER methods for EventDAOService class 
	 * @return
	 */
	public int deleteEventService(int eventId){
		return eventDAO.deleteEvent(eventId);
	}
}
